#include "navbar.h"
#include "ui_navbar.h"
#include <QMouseEvent>

Navbar::Navbar(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Navbar)
{
    ui->setupUi(this);
}

Navbar::~Navbar()
{
    delete ui;
}

void Navbar::on_homeBtn_clicked()
{
    emit homeClicked();
}

void Navbar::on_msgBtn_clicked()
{
    emit msgClicked();
}

void Navbar::on_friendsBtn_clicked()
{
    emit friendsClicked();
}

void Navbar::mousePressEvent(QMouseEvent *event)
{
    if (event->button() == Qt::LeftButton) {
        dragPosition = event->globalPos() - window()->frameGeometry().topLeft();
        event->accept();
    }
}

void Navbar::mouseMoveEvent(QMouseEvent *event)
{
    if (event->buttons() & Qt::LeftButton) {
        window()->move(event->globalPos() - dragPosition);
        event->accept();
    }
}
